import xjaxios from "@/api/axios";
// import xjaxiosThreeline from "@/api/axios-threeline";
export default {
  /**
   * @description: 获取员工列表 *代表必填
   * @param {String/Number} page *
   * @param {String/Number} size *
   * @param {Object} entity {componyId: 1} *
   * @param {String} order 排序方式 ASC DESC 默认ASC
   * @param {String} sort 自定义排序方式 'createTime'
   * @return {Array}
   */
  getUserStaffList(params) {
    return xjaxios.post("v3/virtualSystem/v1/user/queryHome", {
      page: params.page,
      size: params.size,
      // sort: "createTime;timestamp",
      // order: 'desc',
      entity: params.entity
    });
  },

  Syst(formData) {
    return xjaxios.get(`v3/person/person/queryByPersonNo?no=${formData}`);
  },
  /**
   * @description: 新增用户信息
   * @param {Object} formData *
   * @return {Object}
   */
  addUserInfo(formData) {
    formData.or = sessionStorage.baseId;
    formData.systemMark = "OM1";
    return xjaxios.post("powerManage/user/add", formData);
  },
  /**
     * @description: 编辑用户信息
     * @param {Object} formData *
     * @return {Object}
     */
  editUserInfo(formData) {
    return xjaxios.post("v3/virtualSystem/v1/user/edit", formData);
  },
  editpersonInfo(formData) {
    return xjaxios.post("v3/person/person/edit", formData);
  },
  /**
     * @description: 获取功能权限树状图
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  gettreedata() {
    return xjaxios.get("powerManage/functionPermission/queryTreeList", {
      // params: {
      // }
    });
  },
  /**
     * @description: 获取用户所拥有的功能权限
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  getfuncauth(par) {
    return xjaxios.get(`v3/authority/v1/function/getOthers?username=${par}`);
  },
  /**
     * @description: 分配功能权限
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  addfuncauth(par) {
    return xjaxios.post("v3/authority/v1/function/bindUser", par);
  },
  /**
     * @description: 获取数据权限表格
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  gettabledata() {
    return xjaxios.post("powerManage/dataPermission/queryPageList", {
      page: 1,
      size: 10,
      entity: {
        organizationNo: sessionStorage.organizationNo
        // userId: params.id
      }
    });
  },
  /**
     * @description: 获取用户所拥有的数据权限
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  getdatauth(par) {
    return xjaxios.get("powerManage/permission/createAllDataControlByUser", {
      params: {
        organizationNo: sessionStorage.organizationNo,
        userId: par.id
      }
    });
  },
  /**
     * @description: 分配数据权限
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  adddatauth(par) {
    return xjaxios.post("powerManage/permission/disDataPerToUser", {
      organizationNo: sessionStorage.organizationNo,
      userId: par.id,
      dataPermissionIdList: par.permisslist
    });
  },
  /**
     * @description: 获取分配角色多选款
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  getcheckboxdata() {
    return xjaxios.post("v3/authority/v1/role/queryHome",
      {
        "page": 1,
        "size": 1000,
        "entity": {
          "organizationNo": "JiuGuan"
        }
      })
  },
  /**
     * @description: 获取用户所拥有的角色权限
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  getrollehas(par) {
    return xjaxios.get(`v3/authority/v1/role/queryUserRole?username=${par}`);
  },
  /**
     * @description: 分配角色权限
     * @param {String} userId
     * @param {String} system
     * @return {Object}
     */
  // addroleuth(par) {
  //   return xjaxios.post("powerManage/userRoleMapper/addRoleForUser", {
  //     system: "MC",
  //     organizationNo: sessionStorage.organizationNo,
  //     userId: par.id,
  //     roleIdList: par.permisslist
  //   });
  // }
  addroleuth(par) {
    return xjaxios.post("v3/authority/v1/role/bindUser", par);
  },
  // 查询密保问题列表
  getEncryptedquestion(params) {
    return xjaxios.get(`/v3/person/securityQuestion/queryByAccount?account=${params}`)
  },
  // 修改密保
  editEncrypted(params) {
    return xjaxios.post('/v3/person/securityQuestion/resetAnswer', params)
  },
  // 批量添加密保
  addManyEncrypted(params) {
    return xjaxios.post('/v3/person/securityQuestion/addList', params)
  },
  // 修改密码
  editPassword(params,headers) {
    return xjaxios.post('v3/virtualSystem/v1/user/resetPassword',params,headers)
  },
  // 重置密码
  resetPassword(params) {
    return xjaxios.get(`v3/virtualSystem/v1/user/resetInitialPassword?username=${params.username}`)
  },
  // TODO:判断是否是默认密码
  getDefaultPwdStatus(params) {
    return xjaxios.get(`v3/virtualSystem/web/checkDefaultWord?account=${params.username}`)
  },
  // TODO:获取重置后的密码
  getResetPassword() {
    return xjaxios.get('v3/virtualSystem/v1/user/getInitialPassword')
  }
}
